package cn.cs.controller;

import cn.cs.common.Constants;
import cn.cs.common.Dto;
import cn.cs.common.LogUtils;
import cn.cs.service.ItemDetailService;
import cn.cs.service.ParentAndChildService;
import cn.cs.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 商品详情页Controller
 */
@RestController
@RequestMapping(value = "/api")
public class ItemDetailController {

    @Autowired
    private ItemDetailService itemDetailService;

    @Autowired
    private ParentAndChildService parentAndChildService;

    @Resource
    private LogUtils logUtils;
    /**
     * 根据商品id返回商品详情页
     *
     * @param param-id 商品Id
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/p/queryItemDetail",method = RequestMethod.POST)
    @ResponseBody
    public Dto<ItemDetailVo> queryItemDetail(@RequestBody Map<String, Object> param) throws Exception {
        Integer id=Integer.parseInt(param.get("id").toString());
        logUtils.i(Constants.TOPIC.ITEM_CONSUMER,"查询商品ID为"+id+"信息");
        return itemDetailService.queryProductDetail((long) id);
    }

}
